#ifndef SBTLOG_H_INCLUDED
#define SBTLOG_H_INCLUDED

#include "SbtPrerequisites.h"
#include <cstdio>
#include <cstdarg>
#include <string>
#include <fstream>
#include <xlocale>

namespace Sbt
{

class Log
{
public:
    Log(const String& filename = L"SbtLog.log")
        : mLogFileStream(filename.c_str())
    {
        mLogFileStream.imbue(std::locale("chs"));
    }

    void write(const String& infomation)
    {
        mLogFileStream<<infomation<<L"\n";
    }

    std::wofstream& stream()
    {
        return mLogFileStream;
    }

    static Log& instance() {
        static Log mInstance;
        return mInstance;
    }

    static Log* instancePtr() {
        return &instance();
    }
private:
    std::wofstream mLogFileStream;
};

inline void SystemLog(const String& infomation) {
    return Log::instance().write(infomation);
}

inline std::wofstream& LogStream() {
    return Log::instance().stream();
}

} // namespace Sbt

#endif // SBTLOG_H_INCLUDED